#include <QGraphicsSceneMouseEvent>
#include "ui/PointItem.h"

void PointItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        _point->set_x(event->scenePos().x());
        _point->set_y(event->scenePos().y());
        _scene->plotHull();
    }
    QGraphicsEllipseItem::mouseMoveEvent(event);
}

void PointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if (event->buttons() & Qt::RightButton) {
        _scene->removeItem(this);
        _scene->removePoint(_point);
        _scene->plotHull();
    }
    QGraphicsEllipseItem::mousePressEvent(event);
}
